<template>
  <Dialog v-model="dialogVisible" title="导出">
    <div>
      <el-form ref="form" label-width="100px">
        <el-form-item label="导出名称">
          <el-input v-model="params.name" />
        </el-form-item>
        <el-form-item label="导出范围">
          <el-select v-model="params.range" >
            <el-option label="导出全部" value="all" />
            <el-option label="导出选中" value="selected" />
          </el-select>
        </el-form-item>
      </el-form>
    </div>
    <template #footer>
      <el-button plain @click="dialogVisible = false">取 消</el-button>
      <el-button type="primary" @click="confirm">确 认</el-button>
    </template>
  </Dialog>
</template>
<script lang="ts" setup>
  defineOptions({ name: 'ExportFile' })
  const emit = defineEmits(['download'])
  const params = reactive({
    name: '默认名称',
    range: 'all'
  })
  // 弹窗显示值
  const dialogVisible = ref(false)
  // 打开弹窗
  const open = () => {
    dialogVisible.value = true
    params.name = '默认名称'
    params.range = 'all'
  }
  // 暴露方法和数据
  defineExpose({ open, params })
  // 确定操作
  const confirm = () => {
    dialogVisible.value = false
    emit('download')
  }
</script>